function choiceFile(file_path,ch_id){
	var gURL = "/program/admin/zhuanti/filelist.jsp?height=400&width=750&file_path="+file_path+"&ch_id="+ch_id;
	TB_show("文件选择页",gURL,true);
}
function setIndexTemp(cur_page,tem_path,ch_id){
	if(tem_path==""){
		alert("模板不能为空");
		return false;
	}
	if(ch_id!="")
		document.location.href="/program/admin/zhuanti/updateInfo.jsp?tem_path="+tem_path+"&zhuanti_id="+ch_id;
	else
		document.location.href="/program/admin/zhuanti/addInfo.jsp?tem_path="+tem_path;
	TB_remove();
}


//验证只能输入数字和小数点
function clearNoNum(obj){
	//先把非数字的都替换掉，除了数字和.
	obj.value = obj.value.replace(/[^\d.]/g,"");
	//必须保证第一个为数字而不是.
	obj.value = obj.value.replace(/^\./g,"");
	//保证只有出现一个.而没有多个.
	obj.value = obj.value.replace(/\.{2,}/g,".");
	//保证.只出现一次，而不能出现两次以上
	obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
}
// 检测是否为合法数据
function isNum(str) {
	return (str.search(/^\d+(\.\d+)?$/) != -1);
}
function trim(str){
    return str.replace(/(^\s*)|(\s*$)/g,"");
  }//去掉空格

function selectAll(){
	var checkall = document.getElementById('checkall');
	var listsize = document.getElementById('listsize').value;
	for(var i=0;i<listsize;i++){
		if(checkall.checked){
			document.getElementById('checkone'+i).checked = true;
		}else{
			document.getElementById('checkone'+i).checked = false;
		}
	}
}

function delIndexInfo(){
	var listsize = document.getElementById('listsize').value;
	var pkid_string = '';
	var ifcomment='';
	for(var i=0;i<listsize;i++){
		if(document.getElementById('checkone'+i).checked){
			pkid_string += document.getElementById('checkone'+i).value+'|';
		}
	}
	for(var i=0;i<listsize;i++){
		if(document.getElementById('checkone'+i).checked){
		 if(document.getElementById('ckeckcomment'+i).value=='1'){					 
			  ifcomment=1;
			  break;
			}
		}
	} 
	if(pkid_string == ''){
		alert('请至少选择一条!');
		return false;
	}
	document.getElementById('pkid').value = pkid_string;
	document.indexForm.action='/doTradeReg.do';
	if(ifcomment==1){
	   if(window.confirm('您选中的专题下有专题评论，因此不能删除该专题'))
	     return false;
	}
	else if(window.confirm('确认删除吗?')){
		document.indexForm.submit();
	}
}

function deleteOneInfo(pkid,bpm_id,sel){
    var ifcomment = document.getElementById('ckeckcomment'+sel).value;
	if(ifcomment==1){
	   if(window.confirm('您选中的专题下有专题评论，因此不能删除该专题'))
	     return false;	
	}
	else if(window.confirm('确认删除吗？')){
	  window.location.href='/doTradeReg.do?pkid='+pkid+'&bpm_id='+bpm_id;
 	}
}



function subForm(){
	
	if(trim(document.getElementById("title").value)=="")
	{
	  alert("专题标题不能为空！");
	  return ;
	} 
	var cat_id_grou=""; 
	if(document.getElementById('flag_code').value == "0"){
	document.getElementById('cat_id_group').value = document.getElementById('cat_id_group_bak').value;	
	}
		else{
				document.getElementById('cat_id_group').value =="";
				
				  if(document.getElementById("sort1").value!="")
				  {
					  cat_id_grou = document.getElementById("sort1").value+"|"; 
				 

				  if(document.getElementById("sort2").value!="")
				  {
					  cat_id_grou += document.getElementById("sort2").value+"|"; 
				  

				  if(document.getElementById("sort3").value!="")
				  {
					  cat_id_grou += document.getElementById("sort3").value+"|"; 
				  }
				}
			}
				 document.getElementById("cat_id_group").value =cat_id_grou;  
				 //alert(cat_id_grou); 
		     }  
			 if(document.getElementById("cat_id_group").value==""){
			   alert('请选择所属分类');
			   return false; 	//don't forget this , guy! fixed Zhouxq
			 }
			
			 var str=CKEDITOR.instances.content.getData();	                   		 
				str=trim(str);
				if(str==""){
					alert("专题描述不能为空");
					CKEDITOR.instances.content.focus();
						return false;
					}	    
				document.getElementById('zhuan_desc').value	= str ;			
				
				
				
				document.addForm.submit();
}
 

function searchForm(){
	
var class_attr=""; 
  if(document.getElementById("sort1").value!="")
  {
      class_attr = document.getElementById("sort1").value+"|"; 
  }

  if(document.getElementById("sort2").value!="")
  {
      class_attr += document.getElementById("sort2").value+"|"; 
  }

  if(document.getElementById("sort3").value!="")
  {
      class_attr += document.getElementById("sort3").value+"|"; 
  }
  
  document.getElementById("seach_cat_id_group").value = class_attr;	 
	 
	document.indexForm .submit();
	
}

 function sortNews(val)
 {
    var elem=val.form.elements;
    var all_news_text='';
    for(i=0;i<elem.length;i++)
    {
        if(elem[i].type=="text" && elem[i].id!="s_title" && elem[i].id!="s_cust")
        {
      	   all_news_text +=elem[i].id+','+elem[i].value+'|';
        }
    }
 
    document.indexForm.action='/doTradeReg.do';
    document.getElementById("sort").value=all_news_text;
    document.getElementById("bpm_id").value='9538';
    document.indexForm.submit();
 }


var type = "3";

function setSecondClass(val) {
	Ts_categoryInfo.getCatClassByUpId(val, type, setSort2);
}

function setSort2(map_data) {
 	DWRUtil.removeAllOptions("sort2");
	DWRUtil.addOptions("sort2",{"":"请选择"});
	DWRUtil.addOptions("sort2", map_data);
	document.getElementById("sort3").style.display = "none";
	var item = document.getElementById("sort2").length;
	if (item == 0) {
		document.getElementById("sort2").style.display = "none";
	} else {
		document.getElementById("sort2").style.display = "block";
	}
}
// 设置三级分类
function setTherdClass(val) {
	Ts_categoryInfo.getCatClassByUpId(val, type, setSort3);
}
function setSort3(map_data) {
  
	if (map_data != null) {
		DWRUtil.removeAllOptions("sort3");
		DWRUtil.addOptions("sort3",{"":"请选择"});
		DWRUtil.addOptions("sort3", map_data);
		var item = document.getElementById("sort3").length;
		if (item == 0) {
			document.getElementById("sort3").style.display = "none";
		} else {
			document.getElementById("sort3").style.display = "block";
		}
	}
}


function setTypeName1(obj){
	var idx = obj.value;
	$("class_id3").value="";
	$("class_id2").value="";
	$("class_id1").value=idx;
	Ts_categoryInfo.getCatNameById(idx,setClassName1);
}
function setClassName1(val) {
	$("name3").innerHTML = "";
	$("name2").innerHTML = "";
	$("name1").innerHTML = val;
}

function setTypeName2(obj){
	var idx = obj.value;
	$("class_id3").value="";
	$("class_id2").value=idx;
	Ts_categoryInfo.getCatNameById(idx,setClassName2);
}

function setClassName2(val) {
	$("name3").innerHTML = "";
	$("name2").innerHTML = "&nbsp; &gt; " + val + "&nbsp;";
}
function setTypeName3(obj){
	var idx = obj.value;
	$("class_id3").value=idx;
	Ts_categoryInfo.getCatNameById(idx,setClassName3);

	
}
function setClassName3(val) {
	$("name3").innerHTML = "&nbsp; &gt; " + val + "&nbsp;";
}
function ChangeClassStyle(){
	document.getElementById("cat_id_group").value = "";
	document.getElementById("flag_code").value = "1";
	document.getElementById("classId1").style.display="none";
	document.getElementById("classId2").style.display="block";
}


function checkClass( val )
{
	if( CategoryInfo.checkChildren(val) != 0 )
	{
		alert( "请选择完整类型！" );
		return false;
	}
}




function showLinkGoods(){
   var cat_id = document.getElementById('cat_id').value; 
   var brand_id = document.getElementById('brand_id').value;
   var info = document.getElementById('goods_keyword').value;
   var cust_id = document.getElementById('cust_id').value;
   var data = Math.round(Math.random()* 10000);   
   var bURL = "&cat_id="+cat_id+"&brand_id="+brand_id+"&info="+trim(info)+"&cust_id="+cust_id+"&data="+data;
 	//alert(bURL);
   var gURL = "/program/admin/zhuanti/showMoreGoods.jsp?height=380&width=610"+bURL;  
   TB_show("关联商品",gURL,false);                                                       
}


function moveout(k,goods_id){
	var goods_cat_group = document.getElementById("goods_cat_group").value;
	goods_cat_group = goods_cat_group.replace(goods_id+'|','');
	document.getElementById("goods_cat_group").value = goods_cat_group;
	document.getElementById("spandiv"+k).style.display='none';
}


function showassociation(val,title,id){
   var keyword = document.getElementById(val+'_keyword').value;
   var data = Math.round(Math.random()* 10000);   
   var bURL = "&keyword="+trim(keyword)+"&data="+data+"&id="+id+"&val="+val;
   var gURL = "/program/admin/zhuanti/showMoreAssociation.jsp?height=380&width=610"+bURL;   
   TB_show("请选择",gURL,false);                                                       
}

function moveoutguanlian(k,guanlian_id,val){
	var guanlian_id_group = document.getElementById(val+"_id_group").value;	
	guanlian_id_group = guanlian_id_group.replace(guanlian_id+'|','');
	document.getElementById(val+"_id_group").value = guanlian_id_group;
	document.getElementById(val+"spandiv"+k).style.display='none';
	 }
		 
		 
		 
		 